/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package DataAccess;

import Adapter.DomainAdapter;
import Domain.Cluster;
import Domain.HmmStatic;
import Domain.Output;
import java.io.PrintStream;
import Domain.State;
import be.ac.ulg.montefiore.run.jahmm.Hmm;
import be.ac.ulg.montefiore.run.jahmm.ObservationDiscrete;
import java.util.ArrayList;

/**
 *
 * @author Allen
 */
public class StaticsWriter {

    private ArrayList<HmmStatic> statics;
    
    public void setStatics(ArrayList<HmmStatic> statics){
        this.statics = statics;
    }


    public void writeHiddenStates(){

    }

    public void writeClusterInfo(){

    }

    public static void writeSingleOutput(PrintStream ps, Output[] outputs){
        for(int i = 0; i < outputs.length; i ++){
            ps.print(""+outputs[i]+";");
        }
        ps.println();
    }

    public static void writeSingleState(PrintStream ps, State[] states){
        for(int i = 0; i < states.length; i ++){
            ps.print(""+states[i]+";");
        }
        ps.println();
    }

    public static void writeSingleHmm(PrintStream ps, Hmm<ObservationDiscrete<Output>> hmm){
        HmmWriter.writeHmm(ps, hmm);
        ps.println();
    }

    public static void writeSimpleCluster(PrintStream ps, Cluster cluster){
        ps.print("Cluster:");
        HmmWriter.writeHmm(ps, cluster.getAvgHmm());
        ps.println();
    }
    
    public static void writeSingleStatic(PrintStream ps, HmmStatic hmm){
        if(hmm.outputs != null)
            writeSingleOutput(ps, hmm.outputs);
        if(hmm.states != null)
            writeSingleState(ps, hmm.states);
        if(hmm.hmm != null)
            writeSingleHmm(ps, hmm.hmm);
        if(hmm.cluster != null)
            writeSimpleCluster(ps, hmm.cluster);
    }

    public void writeHmmStatics(PrintStream ps){
        for(int i = 0; i < statics.size(); i ++)
            writeSingleStatic(ps, statics.get(i));
    }

    public static void writeClusters(){

    }

}
